package de.teamskill.pux.gui;

import java.awt.BorderLayout;
import java.awt.Color;

import javax.swing.JFrame;
import javax.swing.JScrollPane;

import edu.uci.ics.jung.algorithms.layout.CircleLayout;
import edu.uci.ics.jung.graph.DirectedSparseMultigraph;
import edu.uci.ics.jung.graph.Graph;
import edu.uci.ics.jung.visualization.VisualizationViewer;
import edu.uci.ics.jung.visualization.renderers.DefaultEdgeLabelRenderer;
import edu.uci.ics.jung.visualization.renderers.DefaultVertexLabelRenderer;

/**
 * GPUX
 * 
 * @author <a href="mailto:jfendler@polytechnic.edu.na">Jens Fendler</a>
 * 
 */
public class GPUX extends JFrame {

	public GPUX() {
		super("PUX GUI");
		setupFrame();
	}

	@SuppressWarnings("unchecked")
	private void setupFrame() {
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		getContentPane().setLayout(new BorderLayout());
		Graph<String, Integer> g = getGraph();
		VisualizationViewer vv = new VisualizationViewer(new CircleLayout<String, Integer>(g));
		// vv.setPreferredSize(new Dimension(600, 400));
		vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.BLACK, true));
		vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.BLUE));
		getContentPane().add(new JScrollPane(vv), BorderLayout.CENTER);
		setSize(800, 600);
		setVisible(true);
	}

	private Graph getGraph() {
		Graph<String, Integer> g = new DirectedSparseMultigraph<String, Integer>();
		String node1 = "N1";
		String node2 = "N2";
		String node3 = "N3";
		g.addEdge(2, node1, node2);
		g.addEdge(3, node2, node3);
		g.addEdge(7, node1, node3);
		return g;
	}

	/**
	 * main
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		new GPUX();
	}

}
